<template>
  <div>
    <div
      class="hot-problem"
      v-loading="loading"
    >
      <div class="title">热门问题：</div>
      <ul class="problem-list">
        <li
          class="item"
          v-for="problem of hotProblems"
          :key="problem.id"
          @click="handleProblemClick(problem.id)"
        >
          <span class="dot">·</span>{{problem.title}}
        </li>
      </ul>
    </div>
    <div class="all">
      <span @click="handleShowAllProblem">
        显示全部
        <i class="el-icon-arrow-right"></i><i class="el-icon-arrow-right"></i>
      </span>
    </div>
  </div>
</template>

<script>
import { getSecondRank } from '@/api/guide'
export default {
  name: 'HelpCenter',
  data () {
    return {
      hotProblems: [],
      loading: false
    }
  },
  mounted () {
    this.handleGetSecondRank()
  },
  methods: {
    async  handleGetSecondRank () {
      this.loading = true
      const { data } = await getSecondRank()
      this.hotProblems = data
      this.loading = false
    },
    // 点击全部问题
    handleShowAllProblem () {
      this.$router.push({
        path: '/helpcenterdetail'
      })
    },
    // 点击问题
    handleProblemClick (id) {
      this.$router.push({
        path: '/helpcenterdetail',
        query: {
          helpId: id
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
$item-height: 30px;
.search-box {
  display: flex;
  justify-content: center;
  margin-bottom: 5px;
  .search {
    width: 400px;
    ::v-deep .el-input-group__append {
      background-color: $primary;
      color: #fff;
    }
  }
}
.hot-problem {
  padding: 24px 32px 32px;
  background-color: #fcfcfc;
  border-radius: 10px;
  box-shadow: $shadow;
  .no-result {
    font-size: 14px;
    color: #1c1f21;
  }
  .title {
    font-size: 16px;
    color: $primary;
    line-height: 25px;
    font-weight: 700;
    margin-bottom: 20px;
  }
  .problem-list {
    .item {
      display: inline-block;
      font-size: 14px;
      color: #1c1f21;
      line-height: 24px;
      width: 254px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-right: 18px;
      margin-bottom: 16px;
      &:hover {
        cursor: pointer;
        color: $primary;
      }
      .dot {
        font-weight: 900;
        margin-right: 15px;
        color: #9199a1;
      }
    }
  }
}
.all {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: #9199a1;
  line-height: 18px;
  &:hover {
    cursor: pointer;
    color: $primary;
  }
}
</style>
